package task

import (
	"store/libs/log"
	"time"
)

func Start() {
	/*time.AfterFunc(time.Second, func() {
		nums := 1000000
		w :=sync.WaitGroup{}
		w.Add(nums)

		start := time.Now()
		for index:=0; index <nums; index++ {
			if index%10 == 0 {
				go func(w *sync.WaitGroup) {
					cache.Set(helper.ToString(time.Now().UnixNano()), time.Now().UnixNano(), 0)
					w.Done()
				}(&w)
			}else {
				go func(w *sync.WaitGroup) {
					var value int64
					cache.Get("start", &value)
					w.Done()
				}(&w)
			}
		}
		w.Wait()
		fmt.Printf("%s\n", time.Now().Sub(start).String())
	})*/

	secondTick := time.NewTicker(time.Second)
	minuteTick := time.NewTicker(time.Minute)
	hourTick := time.NewTicker(time.Hour)
	dayTick := time.NewTicker(time.Hour * 24)
	currentTime := time.Now()
	for {
		select {
		case <-secondTick.C:
			currentTime = time.Now()
			//fmt.Printf("second run at %d\n", currentTime)
		case <-minuteTick.C:
			currentTime = time.Now()
			log.Info(nil, "minute run")
		case <-hourTick.C:
			currentTime = time.Now()
			log.Info(nil, "hour run")
		case <-dayTick.C:
			currentTime = time.Now()
			log.Info(nil, "day run")
		}
	}

	currentTime.Unix()
}
